home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / gnome / help / serverguide / C / web-servers.xml < prev    next >
Encoding:
Extensible Markup Language  |  2009-04-28  |  54.1 KB  |  1,242 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" 
  3.     "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
  4. <!ENTITY % globalent SYSTEM "../../libs/global.ent">
  5. %globalent;
  6. <!ENTITY % gnome-menus-C SYSTEM "../../libs/gnome-menus-C.ent">
  7. %gnome-menus-C;
  8. <!ENTITY % xinclude SYSTEM "../../libs/xinclude.mod">
  9. %xinclude;
  10. <!ENTITY language "&EnglishAmerican;">
  11. ]>
  12. <chapter id="web-servers" status="review">
  13.     <title>Web Servers</title>
  14.         <para>A Web server is a software responsible for accepting HTTP requests
  15.     from clients, which are known as Web browsers, and serving them HTTP
  16.     responses along with optional data contents, which usually are Web
  17.     pages such as HTML documents and linked objects (images, etc.).</para>
  18.     <sect1 id="httpd" status="review">
  19.         <title>HTTPD - Apache2 Web Server</title>
  20.       <para>Apache is the most commonly used Web Server on Linux systems. Web Servers are used
  21.           to serve Web Pages requested by client computers. Clients typically request and view
  22.           Web Pages using Web Browser applications such as <application>Firefox</application>,
  23.               <application>Opera</application>, or <application>Mozilla</application>.</para>
  24.       <para>Users enter a Uniform Resource Locator (URL) to point to a Web server by means of
  25.           its Fully Qualified Domain Name (FQDN) and a path to the required resource. For example, to view the home page of
  26.           the <ulink url="&ubuntu-web;">Ubuntu Web site</ulink> a user will enter only the FQDN. To request specific information about 
  27.               <ulink url="&ubuntu-paidsupport;">paid
  28.               support</ulink>, a user will enter the FQDN followed by a path.</para>
  29.       <para>The most common protocol used to transfer Web pages is the Hyper Text Transfer
  30.           Protocol (HTTP). Protocols such as Hyper Text Transfer Protocol over Secure Sockets Layer (HTTPS), and
  31.           File Transfer Protocol (FTP), a protocol for uploading and downloading files, are also
  32.           supported.</para>
  33.       <para>Apache Web Servers are often used in combination with the <application>MySQL</application>
  34.           database engine, the HyperText Preprocessor (<application>PHP</application>)
  35.           scripting language, and other popular scripting languages such as
  36.               <application>Python</application> and <application>Perl</application>. This
  37.           configuration is termed LAMP (Linux, Apache, MySQL and Perl/Python/PHP) and forms a
  38.           powerful and robust platform for the development and deployment of Web-based
  39.           applications.</para>
  40. <sect2 id="http-installation" status="review">
  41.   <title>Installation</title>
  42.     <para>
  43.     The Apache2 web server is available in Ubuntu Linux. To install Apache2:
  44.     </para>
  45.     
  46.     <procedure>
  47.       <step>
  48.         <para>
  49.         At a terminal prompt enter the following command:
  50.         </para>
  51.  
  52. <screen>
  53. <command>sudo apt-get install apache2</command>
  54. </screen>
  55.                       
  56.       </step>
  57.     </procedure>
  58.       
  59.     </sect2>
  60.     <sect2 id="http-configuration" status="review">
  61.         <title>Configuration</title>
  62.  
  63.         <para>
  64.         Apache2 is configured by placing <emphasis>directives</emphasis> in plain text
  65.         configuration files.  The configuration files are separated between the following
  66.         files and directories:
  67.         </para>
  68.  
  69.         <itemizedlist>
  70.           <listitem>
  71.             <para>
  72.             <emphasis>apache2.conf:</emphasis> the main Apache2 configuration file.  Contains settings that 
  73.             are <emphasis>global</emphasis> to Apache2.
  74.             </para>
  75.           </listitem>
  76.           <listitem>
  77.             <para>
  78.             <emphasis>conf.d:</emphasis> contains configuration files which apply <emphasis>globally</emphasis> to Apache. 
  79.             Other packages that use Apache2 to serve content may add files, or symlinks, to this directory.
  80.             </para>
  81.           </listitem>
  82.           <listitem>
  83.             <para>
  84.             <emphasis>envvars:</emphasis> file where Apache2 <emphasis>environment</emphasis> variables are set.
  85.             </para>
  86.           </listitem>
  87.           <listitem>
  88.             <para>
  89.             <emphasis>httpd.conf:</emphasis> historically the main Apache2 configuration file, named after the 
  90.             <application>httpd</application> daemon.  The file can be used for <emphasis>user specific</emphasis> 
  91.             configuration options that globally effect Apache2.
  92.             </para>
  93.           </listitem>
  94.           <listitem>
  95.             <para>
  96.             <emphasis>mods-available:</emphasis> this directory contains configuration files to both load 
  97.             <emphasis>modules</emphasis> and configure them.  Not all modules will have specific configuration files, however.
  98.             </para>
  99.           </listitem>
  100.           <listitem>
  101.             <para>
  102.             <emphasis>mods-enabled:</emphasis> holds <emphasis>symlinks</emphasis> to the files in 
  103.             <filename>/etc/apache2/mods-available</filename>.  When a module configuration file is symlinked it will be enabled 
  104.             the next time <application>apache2</application> is restarted.
  105.             </para>
  106.           </listitem>
  107.           <listitem>
  108.             <para>
  109.             <emphasis>ports.conf:</emphasis> houses the directives that determine which TCP ports Apache2 is listening on.
  110.             </para>
  111.           </listitem>
  112.           <listitem>
  113.             <para>
  114.             <emphasis>sites-available:</emphasis> this directory has configuration files for Apache <emphasis>Virtual Hosts</emphasis>.  
  115.             Virtual Hosts allow Apache2 to be configured for multiple sites that have separate configurations.
  116.             </para>
  117.           </listitem>
  118.           <listitem>
  119.             <para>
  120.             <emphasis>sites-enabled:</emphasis> like mods-enabled, <filename role='directory'>sites-enabled</filename> contains 
  121.             symlinks to the <filename>/etc/apache2/sites-available</filename> directory.  Similarly when a configuration file in 
  122.             sites-available is symlinked it will be active once Apache is restarted.
  123.             </para>
  124.           </listitem>
  125.         </itemizedlist>
  126.  
  127.           <para>
  128.           In addition, other configuration files may be added
  129.           using the <emphasis>Include</emphasis> directive, and wildcards can be used to
  130.           include many configuration files. Any directive may be placed
  131.           in any of these configuration files. Changes to the main
  132.           configuration files are only recognized by Apache2 when it is
  133.           started or restarted.
  134.           </para>
  135.  
  136.           <para>The server also reads a file containing mime document types;
  137.           the filename is set by the <emphasis>TypesConfig</emphasis> directive, and is
  138.           <filename>/etc/mime.types</filename> by default.</para>
  139.  
  140.         <sect3 id="http-basic-settings" status="review">
  141.           <title>Basic Settings</title>
  142.             <para>
  143.              This section explains Apache2 server essential configuration
  144.              parameters. Refer to the <ulink
  145.              url="http://httpd.apache.org/docs/2.2/">Apache2
  146.              Documentation</ulink> for more details.</para>
  147.  
  148.              <itemizedlist>
  149.                <listitem>
  150.                  <para>
  151.                  Apache2 ships with a virtual-host-friendly default configuration.
  152.              That is, it is configured with a single default virtual host (using
  153.          the <emphasis>VirtualHost</emphasis> directive) which can modified or used as-is if you
  154.          have a single site, or used as a template for additional virtual hosts
  155.          if you have multiple sites.  If left alone, the default virtual host
  156.          will serve as your default site, or the site users will see if the
  157.          URL they enter does not match the <emphasis>ServerName</emphasis> directive of any of your 
  158.          custom sites.  To modify the default virtual host, edit the file
  159.          <filename>/etc/apache2/sites-available/default</filename>.
  160.                  </para>
  161.  
  162.                  <note>
  163.                    <para>
  164.                    The directives set for a virtual host only apply to that particular virtual host. If a 
  165.                    directive is set server-wide and not defined within the virtual host settings, the default 
  166.                    setting is used. For example, you can define a Webmaster email address and not define 
  167.                    individual email addresses for each virtual host. 
  168.                    </para>
  169.                  </note>
  170.  
  171.                  <para>
  172.                  If you wish to configure a new virtual host or site, copy that file into the
  173.          same directory with a name you choose.  For example:
  174.                  </para>
  175.  
  176. <screen>
  177. <command>sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/mynewsite</command>
  178. </screen>
  179.  
  180.                  <para>
  181.          Edit the new file to configure the new site using some of the directives
  182.          described below. 
  183.                  </para>
  184.  
  185.                </listitem>
  186.                <listitem>
  187.                  <para>
  188.          The <emphasis>ServerAdmin</emphasis> directive specifies the email address to be advertised
  189.          for the server's administrator.  The default value is webmaster@localhost.
  190.          This should be changed to an email address that is delivered to you (if you
  191.          are the server's administrator).  If your website has a problem, Apache2
  192.          will display an error message containing this email address to report the
  193.          problem to.  Find this directive in your site's configuration file in
  194.          /etc/apache2/sites-available.
  195.          </para>
  196.                </listitem>
  197.                <listitem>
  198.                  <para>
  199.                  The <emphasis>Listen</emphasis> directive specifies the port, and optionally the IP address,
  200.                  Apache2 should listen on. If the IP address is not specified, Apache2
  201.              will listen on all IP addresses assigned to the machine it runs on.
  202.              The default value for the Listen directive is 80.  Change this to
  203.              127.0.0.1:80 to cause Apache2 to listen only on your loopback interface
  204.              so that it will not be available to the Internet, to (for example) 81
  205.                  to change the port that it listens on, or leave it as is for normal
  206.                  operation.  This directive can be found and changed in its own file,
  207.              <filename>/etc/apache2/ports.conf</filename>
  208.                  </para>
  209.                </listitem>
  210.                <listitem>
  211.                  <para>
  212.              The <emphasis>ServerName</emphasis> directive is optional and specifies what FQDN your
  213.          site should answer to.  The default virtual host has no ServerName
  214.          directive specified, so it will respond to all requests that do not
  215.          match a ServerName directive in another virtual host.  If you have
  216.          just acquired the domain name ubunturocks.com and wish to host it on
  217.          your Ubuntu server, the value of the ServerName directive in your
  218.          virtual host configuration file should be ubunturocks.com.  Add this
  219.          directive to the new virtual host file you created earlier 
  220.          (<filename>/etc/apache2/sites-available/mynewsite</filename>).
  221.          </para>
  222.              
  223.                  <para>
  224.                  You may also want your site to respond to www.ubunturocks.com, since
  225.                  many users will assume the www prefix is appropriate.  Use the
  226.          <emphasis>ServerAlias</emphasis> directive for this.  You may also use wildcards in the
  227.          ServerAlias directive.
  228.                  </para>
  229.  
  230.                  <para>
  231.                  For example, the following configuration 
  232.          will cause your site to respond to any domain request ending in
  233.          <emphasis>.ubunturocks.com</emphasis>.
  234.          </para>                 
  235.  
  236. <programlisting>
  237. ServerAlias *.ubunturocks.com
  238. </programlisting>
  239.  
  240.                </listitem>
  241.                <listitem>
  242.                  <para>
  243.          The <emphasis>DocumentRoot</emphasis> directive specifies where Apache should look for the
  244.          files that make up the site.  The default value is /var/www.  No site
  245.          is configured there, but if you uncomment the <emphasis>RedirectMatch</emphasis> directive
  246.          in <filename>/etc/apache2/apache2.conf</filename> requests will be
  247.          redirected to /var/www/apache2-default where the default Apache2 site
  248.          awaits.  Change this value in your site's virtual host file, and
  249.          remember to create that directory if necessary!
  250.          </para>
  251.               </listitem>
  252.             </itemizedlist>
  253.  
  254.         <para>
  255.             The /etc/apache2/sites-available directory is <emphasis role="bold">
  256.             not</emphasis> parsed by Apache2.  Symbolic links in /etc/apache2/sites-enabled
  257.             point to "available" sites. 
  258.             </para>
  259.  
  260.             <para>
  261.             Enable the new <emphasis>VirtualHost</emphasis> using the 
  262.             <application>a2ensite</application> utility and restart Apache:
  263.             </para>
  264.  
  265. <screen>
  266. <command>sudo a2ensite mynewsite</command>
  267. <command>sudo /etc/init.d/apache2 restart</command>
  268. </screen>
  269.  
  270.             <note>
  271.               <para>
  272.               Be sure to replace <emphasis>mynewsite</emphasis> with a more descriptive name for the 
  273.               VirtualHost.  One method is to name the file after the <emphasis>ServerName</emphasis> 
  274.               directive of the VirtualHost.
  275.               </para>
  276.             </note>
  277.            
  278.             <para>
  279.             Similarly, use the <application>a2dissite</application> utility to disable sites.  This is 
  280.             can be useful when troubleshooting configuration problems with multiple VirtualHosts:
  281.             </para>
  282.  
  283. <screen>
  284. <command>sudo a2dissite mynewsite</command>
  285. <command>sudo /etc/init.d/apache2 restart</command>
  286. </screen>
  287.  
  288.         </sect3>
  289.         <sect3 id="default-settings" status="review">
  290.           <title>Default Settings</title>
  291.  
  292.             <para>
  293.             This section explains configuration of the Apache2 server
  294.             default settings.  For example, if you add a virtual host, 
  295.             the settings you configure for the virtual host take
  296.             precedence for that virtual host. For a directive not
  297.             defined within the virtual host settings, the default
  298.             value is used.
  299.             </para>
  300.  
  301.             <itemizedlist>
  302.             <listitem>
  303.  
  304.               <para>
  305.               The <emphasis>DirectoryIndex</emphasis> is the default page served by the
  306.               server when a user requests an index of a directory by
  307.               specifying a forward slash (/) at the end of the directory
  308.               name.
  309.               </para>
  310.  
  311.               <para>
  312.               For example, when a user requests the page
  313.               http://www.example.com/this_directory/, he or she will
  314.               get either the DirectoryIndex page if it exists, a
  315.               server-generated directory list if it does not and the
  316.           Indexes option is specified, or a Permission Denied page
  317.           if neither is true.  The server will try to
  318.               find one of the files listed in the DirectoryIndex
  319.               directive and will return the first one it finds. If it
  320.               does not find any of these files and if Options Indexes is
  321.               set for that directory, the server will generate and
  322.               return a list, in HTML format, of the subdirectories and
  323.               files in the directory.  The default value, found in
  324.           <filename>/etc/apache2/apache2.conf</filename> is "
  325.           index.html index.cgi index.pl index.php index.xhtml".
  326.           Thus, if Apache2 finds a file in a requested directory
  327.           matching any of these names, the first will be displayed.
  328.               </para>
  329.             </listitem>
  330.             <listitem>
  331.  
  332.               <para>
  333.               The <emphasis>ErrorDocument</emphasis> directive allows you to specify a file
  334.                  for Apache to use for specific error events.  For example,
  335.           if a user requests a resource that does not exist, a 404
  336.           error will occur, and per Apache2's default configuration,
  337.           the file <filename>/usr/share/apache2/error/HTTP_NOT_FOUND.html.var
  338.           </filename> will be displayed.  That file is not in the
  339.           server's DocumentRoot, but there is an Alias directive in
  340.           <filename>/etc/apache2/apache2.conf</filename> that redirects
  341.               requests to the /error directory to <filename>/usr/share/apache2/error/</filename>.
  342.               </para>
  343.  
  344.               <para>
  345.           To see a list of the default ErrorDocument directives, use this
  346.           command:
  347.               </para>
  348.  
  349. <screen>
  350. <command>grep ErrorDocument /etc/apache2/apache2.conf</command>
  351. </screen>
  352.  
  353.             </listitem>
  354.             <listitem>
  355.               <para>
  356.               By default, the server writes the transfer log to the file
  357.               <filename>/var/log/apache2/access.log</filename>. You can change this on a per-site
  358.           basis in your virtual host configuration files with the <emphasis>CustomLog</emphasis>
  359.               directive, or omit it to accept the default, specified in <filename>
  360.           /etc/apache2/apache2.conf</filename>.  You may also specify the file
  361.           to which errors are logged, via the <emphasis>ErrorLog</emphasis> directive, whose default
  362.           is <filename>/var/log/apache2/error.log</filename>.  These are kept
  363.           separate from the transfer logs to aid in troubleshooting problems
  364.           with your Apache2 server.  You may also specify the <emphasis>LogLevel</emphasis> (the
  365.           default value is "warn") and the <emphasis>LogFormat</emphasis> (see <filename>
  366.           /etc/apache2/apache2.conf</filename> for the default value).
  367.           </para>
  368.             </listitem>
  369.             <listitem>
  370.               <para>
  371.               Some options are specified on a per-directory basis rather than per-server.
  372.           <emphasis>Options</emphasis> is one of these directives.  A Directory stanza is enclosed in 
  373.           XML-like tags, like so:
  374.               </para>
  375.  
  376. <programlisting>
  377. <Directory /var/www/mynewsite>
  378. ...
  379. </Directory>
  380. </programlisting>
  381.  
  382.         <para>
  383.         The <emphasis>Options</emphasis> directive within a Directory stanza accepts one or more of the
  384.         following values (among others), separated by spaces:
  385.             </para>
  386.  
  387.             <itemizedlist spacing="compact">
  388.               <listitem>
  389.                 <para>
  390.                 <emphasis role="bold">ExecCGI</emphasis> - Allow
  391.                 execution of CGI scripts. CGI scripts are not
  392.                 executed if this option is not chosen.
  393.         <tip>
  394.                   <para>
  395.                   Most files should not be executed as CGI scripts.  This
  396.           would be very dangerous.  CGI scripts should kept in a directory 
  397.           separate from and outside your DocumentRoot, and only this
  398.           directory should have the ExecCGI option set.  This is the default,
  399.           and the default location for CGI scripts is <filename>/usr/lib/cgi-bin</filename>.
  400.           </para>
  401.                 </tip>
  402.         </para>
  403.                 </listitem>
  404.                 <listitem>
  405.                   <para>
  406.                   <emphasis role="bold">Includes</emphasis> - Allow server-side includes.
  407.           Server-side includes allow an HTML file to <emphasis>
  408.           include</emphasis> other files.  This is not a common option.  See
  409.           <ulink url="http://httpd.apache.org/docs/2.2/howto/ssi.html">the Apache2
  410.           SSI HOWTO</ulink> for more information.
  411.                   </para>
  412.                 </listitem>
  413.                 <listitem>
  414.                   <para>
  415.                   <emphasis role="bold">IncludesNOEXEC</emphasis> - Allow server-side includes,
  416.                   but disable the <emphasis>#exec</emphasis> and <emphasis>#include</emphasis>
  417.                   commands in CGI scripts.
  418.                   </para>
  419.                 </listitem>
  420.                 <listitem>
  421.                   <para>
  422.                   <emphasis role="bold">Indexes</emphasis> - Display a formatted list of the
  423.                   directory's contents, if no <emphasis>DirectoryIndex</emphasis> (such as index.html)
  424.                   exists in the requested directory.
  425.                   <caution>
  426.                     <para>
  427.                     For security reasons, this should usually not be set, and certainly
  428.                 should not be set on your DocumentRoot directory.  Enable this option carefully on
  429.             a per-directory basis only if you are certain you want users to see the entire
  430.             contents of the directory.
  431.                     </para>
  432.                   </caution>
  433.                   </para>
  434.                 </listitem>
  435.                 <listitem>
  436.                   <para>
  437.                   <emphasis role="bold">Multiview</emphasis> - Support content-negotiated multiviews;
  438.                   this option is disabled by default for security reasons.  See the <ulink
  439.           url="http://httpd.apache.org/docs/2.2/mod/mod_negotiation.html#multiviews">Apache2
  440.           documentation on this option</ulink>.
  441.                   </para>
  442.                 </listitem>
  443.                 <listitem>
  444.                   <para>
  445.                   <emphasis
  446.                   role="bold">SymLinksIfOwnerMatch</emphasis> - Only follow symbolic links
  447.                   if the target file or directory has the same owner as the link.
  448.                   </para>
  449.                 </listitem>
  450.               </itemizedlist>
  451.             </listitem>
  452.             </itemizedlist>
  453.  
  454.         </sect3>
  455.         <sect3 id="httpd-settings" status="review">
  456.           <title>httpd Settings</title>
  457.   
  458.           <para>
  459.           This section explains some basic <application>httpd</application> daemon configuration settings.
  460.           </para>
  461.  
  462.           <para>
  463.           <emphasis role="bold">LockFile</emphasis> - The LockFile directive sets the path 
  464.           to the lockfile used when the server is compiled with either USE_FCNTL_SERIALIZED_ACCEPT 
  465.       or USE_FLOCK_SERIALIZED_ACCEPT. It must be stored on the local disk. It should be left 
  466.       to the default value unless the logs directory is located on an NFS share. If this is 
  467.       the case, the default value should be changed to a location on the local disk and to a 
  468.       directory that is readable only by root. 
  469.           </para>
  470.  
  471.       <para>
  472.           <emphasis role="bold">PidFile</emphasis> - The PidFile directive sets the file in which the server 
  473.       records its process ID (pid). This file should only be readable by root. In most cases, it should be left 
  474.       to the default value.
  475.           </para>
  476.  
  477.           <para>
  478.           <emphasis role="bold">User</emphasis> - The User directive sets the userid used by the server to answer requests. This 
  479.           setting determines the server's access. Any files inaccessible to this user will also be inaccessible to your website's visitors. 
  480.           The default value for User is www-data. 
  481.           </para>
  482.          
  483.           <warning>
  484.             <para>
  485.             Unless you know exactly what you are doing, do not set the User directive to root. Using root as the User will 
  486.             create large security holes for your Web server. 
  487.             </para>
  488.           </warning>
  489.  
  490.           <para>The Group directive is similar to the User directive. Group sets the group under which the server will answer requests. 
  491.           The default group is also www-data.
  492.           </para>
  493.  
  494.         </sect3>
  495.         <sect3 id="apache-modules" status="review">
  496.           <title>Apache Modules</title>
  497.  
  498.           <para>
  499.           Apache is a modular server. This implies that only the most
  500.           basic functionality is included in the core server. Extended
  501.           features are available through modules which can be loaded
  502.           into Apache. By default, a base set of modules is included in
  503.           the server at compile-time. If the server is compiled to use
  504.           dynamically loaded  modules, then modules can be compiled
  505.           separately, and added at any time using the LoadModule
  506.           directive. Otherwise, Apache must be recompiled to add or
  507.           remove modules. 
  508.           </para>
  509.  
  510.           <para>
  511.           Ubuntu compiles Apache2 to allow the dynamic
  512.           loading of modules.  Configuration directives may be conditionally
  513.       included on the presence of a particular module by enclosing
  514.           them in an <emphasis><IfModule></emphasis> block.
  515.           </para>
  516.  
  517.           <para>
  518.           You can install additional Apache2 modules and use them
  519.           with your Web server.  For example, run the following command from a 
  520.           terminal prompt to install the <emphasis>MySQL Authentication</emphasis> module:
  521.           </para>       
  522.  
  523. <screen>
  524. <command>sudo apt-get install libapache2-mod-auth-mysql</command>
  525. </screen>
  526.  
  527.           <para>
  528.           See the <filename>/etc/apache2/mods-available</filename> directory, for additional modules.
  529.           </para>
  530.  
  531.           <para>
  532.           Use the <application>a2enmod</application> utility to
  533.           enable a module:
  534.           </para>
  535.  
  536. <screen>
  537. <command>sudo a2enmod auth_mysql</command>
  538. <command>sudo /etc/init.d/apache2 restart</command>
  539. </screen>
  540.  
  541.           <para>
  542.           Similarly, <application>a2dismod</application> will disable a module:
  543.           </para>
  544.  
  545. <screen>
  546. <command>sudo a2dismod auth_mysql</command>
  547. <command>sudo /etc/init.d/apache2 restart</command>
  548. </screen>
  549.  
  550.         </sect3>
  551.       </sect2>
  552.       <sect2 id="https-configuration" status="review">
  553.         <title>HTTPS Configuration</title>
  554.  
  555.           <para>
  556.           The <application>mod_ssl</application> module adds
  557.           an important feature to the Apache2 server - the ability to
  558.           encrypt communications.  Thus, when your browser is
  559.           communicating using SSL, the
  560.           https:// prefix is used at the beginning of the Uniform
  561.           Resource Locator (URL) in the browser navigation bar.
  562.           </para>
  563.  
  564.           <para>
  565.           The <application>mod_ssl</application> module is available in
  566.           <application>apache2-common</application> package. Execute the following command from a terminal prompt to
  567.           enable the <application>mod_ssl</application> module:
  568.           </para>
  569.          
  570. <screen>
  571. <command>sudo a2enmod ssl</command>
  572. </screen>         
  573.  
  574.           <para>
  575.           There is a default HTTPS configuration file in <filename>/etc/apache2/sites-available/default-ssl</filename>.
  576.           In order for <application>Apache</application> to provide HTTPS, 
  577.           a <emphasis>certificate</emphasis> and <emphasis>key</emphasis> file are also needed.  The default HTTPS 
  578.           configuration will use a certificate and key generated by the <application>ssl-cert</application> package.  They 
  579.           are good for testing, but the auto-generated certificate and key should be replaced by a certificate specific
  580.           to the site or server. For information on generating a key and obtaining a certificate see 
  581.           <xref linkend="certificates-and-security"/>
  582.           </para>
  583.  
  584.       <para>
  585.           To configure <application>Apache</application> for HTTPS, enter the following:
  586.           </para>
  587.  
  588. <screen>
  589. <command>sudo a2ensite default-ssl</command>
  590. </screen>
  591.  
  592.             <note>
  593.               <para>
  594.               The directories <filename>/etc/ssl/certs</filename> and <filename>/etc/ssl/private</filename> are the
  595.               default locations.  If you install the certificate and key in another directory make sure to change
  596.               <emphasis>SSLCertificateFile</emphasis> and <emphasis>SSLCertificateKeyFile</emphasis> appropriately.
  597.               </para>
  598.             </note>
  599.  
  600.             <para>
  601.             With Apache now configured for HTTPS, restart the service to enable the new settings:
  602.             </para>
  603.  
  604.             
  605. <screen>
  606. <command>sudo /etc/init.d/apache2 restart</command>
  607. </screen>
  608.             
  609.  
  610.             <note>
  611.               <para>
  612.               Depending on how you obtained your certificate you may need to 
  613.               enter a passphrase when <application>Apache</application> starts. 
  614.               </para>
  615.             </note>
  616.  
  617.             <para>
  618.          You can access the secure server pages by typing
  619.             https://your_hostname/url/ in your browser address bar.
  620.             </para>
  621.  
  622.       </sect2>
  623.       <sect2 id="http-references" status="review">
  624.         <title>References</title>
  625.  
  626.           <itemizedlist>
  627.             <listitem>
  628.             <para>
  629.             <ulink url="http://httpd.apache.org/docs/2.2/">Apache2 Documentation</ulink> contains in depth
  630.             information on Apache2 configuration directives. Also, see the <application>apache2-doc</application> 
  631.             package for the official Apache2 docs.
  632.             </para>
  633.           </listitem>
  634.           <listitem>
  635.             <para>
  636.             See the <ulink url="http://www.modssl.org/docs/">Mod SSL Documentation</ulink> site for more
  637.             SSL related information.
  638.             </para>
  639.           </listitem>
  640.           <listitem>
  641.             <para>
  642.             O'Reilly's <ulink url="http://oreilly.com/catalog/9780596001919/">Apache Cookbook</ulink> is 
  643.             a good resource for accomplishing specific Apache2 configurations.
  644.             </para>
  645.           </listitem>
  646.           <listitem>
  647.             <para>
  648.             For Ubuntu specific Apache2 questions, ask in the <emphasis>#ubuntu-server</emphasis> IRC channel on 
  649.             <ulink url="http://freenode.net/">freenode.net</ulink>.
  650.             </para>
  651.           </listitem>
  652.         </itemizedlist>
  653.  
  654.       </sect2>
  655.     </sect1>
  656.  
  657.     <sect1 id="php5" status="review">
  658.         <title>PHP5 - Scripting Language</title>
  659.       <para>PHP is a general-purpose scripting language suited for Web
  660.       development. The PHP script can be embedded into HTML. This
  661.       section explains how to install and configure PHP5 in Ubuntu
  662.       System with Apache2 and MySQL.</para>
  663.       <para> This section assumes you have installed and configured
  664.       Apache 2 Web Server and MySQL Database Server. You can refer to
  665.       Apache 2 section and MySQL sections in this document to install and
  666.       configure Apache 2 and MySQL respectively.</para>
  667.  
  668. <sect2 id="php5-installation" status="review">
  669.   <title>Installation</title>
  670.       <para>The PHP5 is available in Ubuntu Linux. </para>
  671.       
  672.       <procedure><step><para>
  673.       To install PHP5 you
  674.       can enter the following command in the terminal prompt:
  675.  
  676. <screen>
  677. <command>sudo apt-get install php5 libapache2-mod-php5</command>
  678. </screen>
  679. </para>
  680.  
  681.       <para>You can run PHP5 scripts from command line. To run PHP5 scripts 
  682.       from command line you should install
  683.       <application>php5-cli</application> package. To install
  684.       <application>php5-cli</application> you can enter the following
  685.       command in the terminal prompt:
  686. <screen>
  687. <command>sudo apt-get install php5-cli</command>
  688. </screen>
  689. </para>
  690.       <para>
  691.       You can also execute PHP5 scripts without installing PHP5 Apache
  692.       module. To accomplish this, you should install
  693.       <application>php5-cgi</application> package. You can run the
  694.       following command in a terminal prompt to install
  695.       <application>php5-cgi</application> package:
  696. <screen>
  697. <command>sudo apt-get install php5-cgi</command>
  698. </screen>
  699.       </para>
  700.       <para>To use <application>MySQL</application> with PHP5 you should install
  701.       <application>php5-mysql</application> package. To install
  702.       <application>php5-mysql</application> you can enter the following
  703.       command in the terminal prompt:
  704. <screen>
  705. <command>sudo apt-get install php5-mysql</command>
  706. </screen>
  707. </para>
  708.       <para>Similarly, to use <application>PostgreSQL</application> with PHP5 you should install
  709.       <application>php5-pgsql</application> package. To install
  710.       <application>php5-pgsql</application> you can enter the following
  711.       command in the terminal prompt:
  712. <screen>
  713. <command>sudo apt-get install php5-pgsql</command>
  714. </screen>
  715.       </para>
  716.             </step>
  717.         </procedure>
  718.       </sect2>
  719.       <sect2 id="php5-configuration" status="review">
  720.         <title>Configuration</title>
  721.           <para>
  722.           Once you install PHP5, you can run PHP5 scripts from your web
  723.           browser. If you have installed
  724.           <application>php5-cli</application> package, you can run PHP5
  725.           scripts from your command prompt.
  726.           </para>
  727.  
  728.           <para>
  729.           By default, the Apache 2 Web server is configured to run PHP5
  730.           scripts. In other words, the PHP5 module is enabled in Apache2
  731.           Web server automatically when you install the module. Please
  732.           verify if the files
  733.           <filename>/etc/apache2/mods-enabled/php5.conf</filename> and
  734.           <filename>/etc/apache2/mods-enabled/php5.load</filename>
  735.           exist. If they do not exists, you can enable the module using
  736.           <command>a2enmod</command> command.
  737.           </para>
  738.  
  739.           <para>Once you install PHP5 related packages and enabled PHP5
  740.           Apache 2 module, you should restart Apache2 Web server to run
  741.           PHP5 scripts. You can run the following command at a terminal
  742.           prompt to restart your web server:
  743. <screen><command>sudo /etc/init.d/apache2 restart</command> </screen>
  744.           </para>
  745.       </sect2>
  746.       <sect2 id="php5-testing" status="review">
  747.         <title>Testing</title>
  748.           <para>To verify your installation, you can run following PHP5
  749.           phpinfo script:
  750.           </para>
  751. <programlisting>
  752. <?php
  753. print_r (phpinfo());
  754. ?>
  755. </programlisting>
  756.           <para>
  757.           You can save the content in a file
  758.           <filename>phpinfo.php</filename> and place it
  759.           under <command>DocumentRoot</command> directory of Apache2 Web
  760.           server. When point your browser to
  761.           <filename>http://hostname/phpinfo.php</filename>, it would
  762.           display values of various PHP5 configuration parameters.
  763.       </para>
  764.       </sect2>
  765.       <sect2 id="php5-references">
  766.         <title>References</title>
  767.  
  768.         <itemizedlist>
  769.           <listitem>
  770.             <para>
  771.             For more in depth information see <ulink url="http://www.php.net/docs.php">php.net</ulink> documentation.
  772.             </para> 
  773.           </listitem>
  774.           <listitem>
  775.             <para>
  776.             There are a plethora of books on PHP.  Two good books from O'Reilly are 
  777.             <ulink url="http://oreilly.com/catalog/9780596005603/">Learning PHP 5</ulink> and the
  778.             <ulink url="http://oreilly.com/catalog/9781565926813/">PHP Cook Book</ulink>.
  779.             </para> 
  780.           </listitem>
  781.         </itemizedlist>
  782.  
  783.       </sect2>
  784.     </sect1>
  785.     
  786.     <sect1 id="squid" status="review">
  787.         <title>Squid - Proxy Server</title>
  788.           <para>
  789.           Squid is a full-featured web proxy cache server application which provides proxy and cache services for Hyper Text
  790.           Transport Protocol (HTTP), File Transfer Protocol (FTP), and other popular network protocols.  Squid can implement
  791.           caching and proxying of Secure Sockets Layer (SSL) requests and caching of Domain Name Server (DNS) lookups, and perform
  792.           transparent caching. Squid also supports a wide variety of caching protocols, such as Internet Cache Protocol, (ICP)
  793.           the Hyper Text Caching Protocol, (HTCP) the Cache Array Routing Protocol (CARP), and the Web Cache Coordination 
  794.           Protocol. (WCCP) 
  795.           </para>
  796.           <para>
  797.           The Squid proxy cache server is an excellent solution to a variety of proxy and caching server needs, and scales from
  798.           the branch office to enterprise level networks while providing extensive, granular access control mechanisms and
  799.           monitoring of critical parameters via the Simple Network Management Protocol (SNMP).  When selecting a computer system
  800.           for use as a dedicated Squid proxy, or caching servers, ensure your system is configured with a large amount of physical
  801.           memory, as Squid maintains an in-memory cache for increased performance.
  802.           </para>
  803.       <sect2 id="squid-installation" status="review">
  804.         <title>Installation</title>
  805.           <para>
  806.             At a terminal prompt, enter the following command to install the Squid server:
  807.           </para>
  808.           <para>
  809. <screen>
  810. <command>sudo apt-get install squid</command>
  811. </screen>
  812.           </para>
  813.       </sect2>
  814.       <sect2 id="squid-configuration" status="review">
  815.         <title>Configuration</title>
  816.           <para>
  817.             Squid is configured by editing the directives contained within the <filename>/etc/squid/squid.conf</filename> configuration file.
  818.             The following examples illustrate some of the directives which may be modified to affect the behavior of the Squid server.
  819.             For more in-depth configuration of Squid, see the References section. 
  820.           </para>
  821.              <tip>
  822.                <para>Prior to editing the configuration file, you should make a copy of the original file and protect it 
  823.                from writing so you will have the original settings as a reference, and to re-use as necessary.
  824.                </para>
  825.                <para>Copy the <filename>/etc/squid/squid.conf</filename> file and protect it from writing with the following commands entered at a terminal prompt:
  826.                </para>
  827.          </tip>
  828.                <para>
  829. <screen>
  830. <command>sudo cp /etc/squid/squid.conf /etc/squid/squid.conf.original</command>
  831. <command>sudo chmod a-w /etc/squid/squid.conf.original</command>
  832. </screen>
  833.                </para> 
  834.             <para>
  835.            <itemizedlist>
  836.                <listitem>
  837.                   <para>
  838.                   To set your Squid server to listen on TCP port 8888 instead of the default TCP port 3128, change
  839.                   the http_port directive as such:
  840.                   </para>
  841. <programlisting>
  842. http_port 8888
  843. </programlisting>
  844.                </listitem>
  845.                 <listitem>
  846.                   <para>
  847.                   Change the visible_hostname directive in order to give the Squid server a specific hostname.  This hostname
  848.                   does not necessarily need to be the computer's hostname. In this example it is set to <emphasis>weezie</emphasis>
  849.                   </para>
  850. <programlisting>
  851. visible_hostname weezie
  852. </programlisting>
  853.                </listitem>
  854.                <listitem>
  855.                   <para>
  856.                      Again, Using Squid's access control, you may configure use of Internet services proxied by Squid
  857.                      to be available only users with certain Internet Protocol (IP) addresses.  For example, we will illustrate access 
  858.                      by users of the 192.168.42.0/24 subnetwork only:
  859.                   </para>
  860.                   <para>
  861.                      Add the following to the <emphasis role="bold">bottom</emphasis> of the ACL section of your <filename>/etc/squid/squid.conf</filename> file:
  862.                   </para>
  863. <programlisting>
  864. acl fortytwo_network src 192.168.42.0/24
  865. </programlisting>
  866.                   <para>
  867.                      Then, add the following to the <emphasis role="bold">top</emphasis> of the http_access section of your
  868.                      <filename>/etc/squid/squid.conf</filename> file:
  869.                   </para>
  870. <programlisting>
  871. http_access allow fortytwo_network
  872. </programlisting>
  873.                </listitem>
  874.                <listitem>
  875.                   <para>
  876.                      Using the excellent access control features of Squid, you may configure use of Internet services proxied by Squid
  877.                      to be available only during normal business hours.  For example, we'll illustrate access by employees of a business
  878.                      which is operating between 9:00AM and 5:00PM, Monday through Friday, and which uses the 10.1.42.0/42 subnetwork:
  879.                   </para>
  880.                   <para>
  881.                      Add the following to the <emphasis role="bold">bottom</emphasis> of the ACL section of your <filename>/etc/squid/squid.conf</filename> file:
  882.                   </para>
  883. <programlisting>
  884. acl biz_network src 10.1.42.0/24
  885. acl biz_hours time M T W T F 9:00-17:00
  886. </programlisting>
  887.                   <para>
  888.                      Then, add the following to the <emphasis role="bold">top</emphasis> of the http_access section of your
  889.                      <filename>/etc/squid/squid.conf</filename> file:
  890.                   </para>
  891. <programlisting>
  892. http_access allow biz_network biz_hours
  893. </programlisting>
  894.                </listitem>
  895.           </itemizedlist>
  896.           </para>
  897.           <note>
  898.       <para>
  899.           After making changes to the <filename>/etc/squid/squid.conf</filename> file, save the file and restart the <application>squid</application> 
  900.           server application to effect the changes using the following command entered at a terminal prompt:
  901.           </para>
  902.           </note>
  903.           <para>
  904. <screen>
  905. <command>sudo /etc/init.d/squid restart</command>
  906. </screen>
  907.           </para>
  908.       </sect2>
  909.       <sect2 id="squid-references" status="review">
  910.       <title>References</title>
  911.       <para>
  912.       <ulink url="http://www.squid-cache.org/">Squid Website</ulink>
  913.       </para>
  914.       </sect2>
  915.     </sect1>
  916.  
  917.     <sect1 id="ruby-on-rails" status="review">
  918.         <title>Ruby on Rails</title>
  919.     <para>Ruby on Rails is an open source web framework for developing
  920.     database backed web applications. It is optimized for sustainable
  921.     productivity of the programmer since it lets the programmer to write
  922.     code by favouring convention over configuration.</para>
  923.  
  924.     <sect2 id="ruby-on-rails-installation" status="review">
  925.       <title>Installation</title>
  926.         <para>
  927.         Before installing <application>Rails</application> you should install <application>Apache</application>
  928.         and <application>MySQL</application>.
  929.         To install the <application>Apache</application> package, please refer to
  930.         <xref linkend="httpd"/>.  For instructions on installing 
  931.         <application>MySQL</application> refer to
  932.         <xref linkend="mysql"/>.
  933.     </para>
  934.       <para>
  935.           Once you have <application>Apache</application> and
  936.         <application>MySQL</application> packages installed,
  937.           you are ready to install <application>Ruby on
  938.         Rails</application> package.
  939.       </para>     
  940.     
  941.       <para> 
  942.       To install the <application>Ruby</application> base packages and
  943.       <application>Ruby on Rails</application>,
  944.       you can enter the following command in the terminal prompt:
  945.       </para>
  946. <screen>
  947. <command>sudo apt-get install rails</command>
  948. </screen>
  949.     
  950.     </sect2>
  951.     <sect2 id="ruby-on-rails-configuration" status="review">
  952.     <title>Configuration</title>    
  953.     <para>
  954.         Modify the <filename>/etc/apache2/sites-available/default</filename>
  955.     configuration file to setup your domains.
  956.     </para>
  957.     <para>
  958.         The first thing to change is the <emphasis>DocumentRoot</emphasis>
  959.       directive:
  960.     </para>
  961. <programlisting>
  962. DocumentRoot /path/to/rails/application/public
  963. </programlisting>
  964.     <para>
  965.         Next, change the <Directory
  966.       "/path/to/rails/application/public"> directive:
  967.     </para>
  968. <programlisting>
  969. <Directory "/path/to/rails/application/public">
  970.         Options Indexes FollowSymLinks MultiViews ExecCGI
  971.         AllowOverride All
  972.         Order allow,deny
  973.         allow from all
  974.         AddHandler cgi-script .cgi
  975. </Directory>
  976. </programlisting>
  977.     
  978.     <para>
  979.     You should also enable the <application>mod_rewrite</application>
  980.     module for Apache.  To enable <application>mod_rewrite</application>
  981.     module, please enter the following command in a terminal prompt: 
  982.     </para>
  983. <screen>
  984. <command>sudo a2enmod rewrite</command>
  985. </screen>
  986.    
  987.     <para>
  988.     Finally you will need to change the ownership of the <filename>/path/to/rails/application/public</filename>
  989.     and <filename>/path/to/rails/application/tmp</filename> directories to the user used to run the 
  990.     <application>Apache</application> process:
  991.     </para>
  992. <screen>
  993. <command>sudo chown -R www-data:www-data /path/to/rails/application/public</command>
  994. <command>sudo chown -R www-data:www-data /path/to/rails/application/tmp</command>
  995. </screen>
  996.  
  997.     <para>That's it! Now you have your Server ready for your
  998.     <application>Ruby on Rails</application> applications.
  999.     </para>
  1000.     </sect2>
  1001.     <sect2 id="ruby-on-rails-references" status="review">
  1002.       <title>References</title>
  1003.  
  1004.         <itemizedlist>
  1005.           <listitem>
  1006.             <para>
  1007.             See the <ulink url="http://rubyonrails.org/">Ruby on Rails</ulink> website for more information.
  1008.             </para>
  1009.           </listitem>
  1010.           <listitem>
  1011.             <para>
  1012.             Also <ulink url="http://pragprog.com/titles/rails3/agile-web-development-with-rails-third-edition">Agile Development with Rails</ulink>
  1013.             is a great resource.
  1014.             </para>
  1015.           </listitem>
  1016.         </itemizedlist>
  1017.  
  1018.     </sect2>
  1019.   </sect1>
  1020.  
  1021.     <sect1 id="tomcat" status="review">
  1022.         <title>Apache Tomcat</title>
  1023.         <para>Apache Tomcat is a web container that allows you to serve Java Servlets
  1024.         and JSP (Java Server Pages) web applications.</para>
  1025.         <para>The <application>Tomcat 6.0</application> packages in Ubuntu support
  1026.         two different ways of running Tomcat. You can install them as a classic
  1027.         unique system-wide instance, that will be started at boot time and will run
  1028.         as the tomcat6 unpriviledged user. But you can also deploy private
  1029.         instances that will run with your own user rights, and that you should
  1030.         start and stop by yourself. This second way is particularly useful in a
  1031.         development server context where multiple users need to test on their own
  1032.         private Tomcat instances.</para>
  1033.  
  1034.         <sect2 id="tomcat-installation" status="review">
  1035.             <title>System-wide installation</title>
  1036.             <para>To install the <application>Tomcat</application> server,
  1037.             you can enter the following command in the terminal prompt:</para>
  1038. <screen>
  1039. <command>sudo apt-get install tomcat6</command>
  1040. </screen>
  1041.             <para>This will install a Tomcat server with just a default ROOT webapp
  1042.             that displays a minimal "It works" page by default.</para>
  1043.         </sect2>
  1044.  
  1045.     <sect2 id="tomcat-configuration" status="review">
  1046.         <title>Configuration</title>    
  1047.         <para>Tomcat configuration files can be found in
  1048.             <filename>/etc/tomcat6</filename>. Only a few common configuration tweaks
  1049.             will be described here, please see
  1050.             <ulink url="http://tomcat.apache.org/tomcat-6.0-doc/index.html">Tomcat
  1051.             6.0 documentation</ulink> for more.</para>
  1052.             <sect3 id="tomcat-configuration-ports" status="review">
  1053.                 <title>Changing default ports</title>
  1054.                 <para>By default Tomcat 6.0 runs a HTTP connector on port 8080 and an
  1055.                 AJP connector on port 8009. You might want to change those default
  1056.                 ports to avoid conflict with another server on the system. This is
  1057.                 done by changing the following lines in
  1058.                 <filename>/etc/tomcat6/server.xml</filename>:</para>
  1059. <programlisting>
  1060. <Connector port="8080" protocol="HTTP/1.1" 
  1061.                connectionTimeout="20000" 
  1062.                redirectPort="8443" />
  1063. ...
  1064. <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
  1065. </programlisting>
  1066.             </sect3>
  1067.             <sect3 id="tomcat-configuration-jvm" status="review">
  1068.                 <title>Changing JVM used</title>
  1069.                 <para>By default Tomcat will run preferably with OpenJDK-6, then try
  1070.                 Sun's JVM, then try some other JVMs. If you have various JVMs
  1071.                 installed, you can set which should be used by setting JAVA_HOME in
  1072.                 <filename>/etc/default/tomcat6</filename>:</para>
  1073. <programlisting>
  1074. JAVA_HOME=/usr/lib/jvm/java-6-sun
  1075. </programlisting>
  1076.             </sect3>
  1077.             <sect3 id="tomcat-configuration-users" status="review">
  1078.                 <title>Declaring users and roles</title>
  1079.                 <para>Usernames, passwords and roles (groups) can be defined centrally
  1080.                 in a Servlet container. In Tomcat 6.0 this is done in the
  1081.                 <filename>/etc/tomcat6/tomcat-users.xml</filename> file:</para>
  1082. <programlisting>
  1083. <role rolename="admin"/>
  1084. <user username="tomcat" password="s3cret" roles="admin"/>
  1085. </programlisting>
  1086.             </sect3>
  1087.     </sect2>
  1088.  
  1089.         <sect2 id="tomcat-webapps" status="review">
  1090.             <title>Using Tomcat standard webapps</title>
  1091.             <para>Tomcat is shipped with webapps that you can install
  1092.             for documentation, administration or demo purposes.</para>
  1093.             <sect3 id="tomcat-installation-docs" status="review">
  1094.                 <title>Tomcat documentation</title>
  1095.                 <para>The <application>tomcat6-docs</application> package contains
  1096.                 Tomcat 6.0 documentation, packaged as a webapp that you can access by
  1097.                 default at http://yourserver:8080/docs. You can install it by entering
  1098.                 the following command in the terminal prompt:</para>
  1099. <screen>
  1100. <command>sudo apt-get install tomcat6-docs</command>
  1101. </screen>
  1102.             </sect3>
  1103.             <sect3 id="tomcat-installation-admin" status="review">
  1104.                 <title>Tomcat administration webapps</title>
  1105.                 <para>The <application>tomcat6-admin</application> package contains
  1106.                 two webapps that can be used to administer the Tomcat server using a
  1107.                 web interface. You can install them by entering the
  1108.                 following command in the terminal prompt:</para>
  1109. <screen>
  1110. <command>sudo apt-get install tomcat6-admin</command>
  1111. </screen>
  1112.                 <para>The first one is the <emphasis>manager</emphasis> webapp, which
  1113.                 you can access by default at http://yourserver:8080/manager/html. It is
  1114.                 primarily used to get server status and restart webapps.</para>
  1115.                 <note><para>Access to the <emphasis>manager</emphasis> application is
  1116.                 protected by default: you need to define a user with the role "manager"
  1117.                 in <filename>/etc/tomcat6/tomcat-users.xml</filename>
  1118.                 before you can access it.</para></note>
  1119.                 <para>The second one is the <emphasis>host-manager</emphasis> webapp,
  1120.                 which you can access by default at
  1121.                 http://yourserver:8080/host-manager/html.
  1122.                 It can be used to create virtual hosts dynamically.</para>
  1123.                 <note><para>Access to the <emphasis>host-manager</emphasis> application is
  1124.                 also protected by default: you
  1125.                 need to define a user with the role "admin" in
  1126.                 <filename>/etc/tomcat6/tomcat-users.xml</filename>
  1127.                 before you can access it.</para></note>
  1128.                 <para>For security reasons, the tomcat6 user cannot write to the
  1129.                 <filename>/etc/tomcat6</filename> directory by default. Some features
  1130.                 in these admin webapps (application deployment, virtual host creation)
  1131.                 need write access to that directory. If you want to use these
  1132.                 features execute the following, to give users in the tomcat6 group the necessary
  1133.                 rights:</para>
  1134. <screen>
  1135. <command>sudo chgrp -R tomcat6 /etc/tomcat6</command>
  1136. <command>sudo chmod -R g+w /etc/tomcat6</command> 
  1137. </screen>
  1138.  
  1139.             </sect3>
  1140.             <sect3 id="tomcat-installation-examples" status="review">
  1141.                 <title>Tomcat examples webapps</title>
  1142.                 <para>The <application>tomcat6-examples</application> package contains
  1143.                 two webapps that can be used to test or demonstrate Servlets and JSP
  1144.                 features, which you can access them by default at
  1145.                 http://yourserver:8080/examples. You can install them by entering the
  1146.                 following command in the terminal prompt:</para>
  1147. <screen>
  1148. <command>sudo apt-get install tomcat6-examples</command>
  1149. </screen>
  1150.             </sect3>
  1151.     </sect2>
  1152.  
  1153.         <sect2 id="tomcat-user" status="review">
  1154.             <title>Using private instances</title>    
  1155.             <para>Tomcat is heavily used in development and testing scenarios
  1156.             where using a single system-wide instance doesn't meet the requirements
  1157.             of multiple users on a single system. The Tomcat 6.0 packages in
  1158.             Ubuntu come with tools to help deploy your own user-oriented instances,
  1159.             allowing every user on a system to run (without root rights) separate
  1160.             private instances while still using the system-installed
  1161.             libraries.</para>
  1162.             <note><para>It is possible to run the system-wide instance and the private
  1163.             instances in parallel, as long as they do not use the same TCP
  1164.             ports.</para></note>
  1165.             <sect3 id="tomcat-user-install" status="review">
  1166.                 <title>Installing private instance support</title>
  1167.                 <para>You can install everything necessary to run private instances
  1168.                 by entering the following command in the terminal prompt:</para>
  1169. <screen>
  1170. <command>sudo apt-get install tomcat6-user</command>
  1171. </screen>
  1172.             </sect3>
  1173.             <sect3 id="tomcat-user-create" status="review">
  1174.                 <title>Creating a private instance</title>
  1175.                 <para>You can create a private instance directory by entering the
  1176.                 following command in the terminal prompt:</para>
  1177. <screen>
  1178. <command>tomcat6-instance-create my-instance</command>
  1179. </screen>
  1180.                 <para>This will create a new <filename>my-instance</filename> directory
  1181.                 with all the necessary subdirectories and scripts.
  1182.                 You can for example install your common libraries in the
  1183.                 <filename>lib/</filename> subdirectory and deploy your webapps in the
  1184.                 <filename>webapps/</filename> subdirectory. No webapps are deployed
  1185.                 by default.</para>
  1186.             </sect3>
  1187.             <sect3 id="tomcat-user-config" status="review">
  1188.                 <title>Configuring your private instance</title>
  1189.                 <para>You will find the classic Tomcat configuration files for your
  1190.                 private instance in the <filename>conf/</filename>
  1191.                 subdirectory. You should for
  1192.                 example certainly edit the <filename>conf/server.xml</filename> file
  1193.                 to change the default ports used by your private Tomcat instance to
  1194.                 avoid conflict with other instances that might be running.</para>
  1195.             </sect3>
  1196.             <sect3 id="tomcat-user-start" status="review">
  1197.                 <title>Starting/stopping your private instance</title>
  1198.                 <para>You can start your private instance by entering the following
  1199.                 command in the terminal prompt (supposing  your instance is located
  1200.                 in the <filename>my-instance</filename> directory):</para>
  1201. <screen>
  1202. <command>my-instance/bin/startup.sh</command>
  1203. </screen>
  1204.                 <note><para>You should check the <filename>logs/</filename> subdirectory for
  1205.                 any error. If you have a <emphasis>java.net.BindException: Address
  1206.                 already in use<null>:8080</emphasis> error, it means that the
  1207.                 port you're using is already taken and that you should change it.
  1208.                 </para></note>
  1209.                 <para>You can stop your instance by entering the following
  1210.         command in the terminal prompt (supposing  your instance is located
  1211.         in the <filename>my-instance</filename> directory):</para>
  1212. <screen>
  1213. <command>my-instance/bin/shutdown.sh</command>
  1214. </screen>
  1215.             </sect3>
  1216.         </sect2>
  1217.                 <sect2 id="tomcat-references" status="review">
  1218.                   <title>References</title>
  1219.  
  1220.                   <itemizedlist>
  1221.                     <listitem>
  1222.                       <para>
  1223.                       See the <ulink url="http://tomcat.apache.org/">Apache Tomcat</ulink> website for more information.
  1224.                       </para>
  1225.                     </listitem>
  1226.                     <listitem>
  1227.                       <para>
  1228.                       <ulink url="http://oreilly.com/catalog/9780596003180/">Tomcat: The Definitive Guide</ulink> is a good
  1229.                       resource for building web applications with Tomcat.
  1230.                       </para>
  1231.                     </listitem>
  1232.                     <listitem>
  1233.                       <para>
  1234.                       For additional books see the <ulink url="http://wiki.apache.org/tomcat/Tomcat/Books">Tomcat Books</ulink> list page.
  1235.                       </para>
  1236.                     </listitem>
  1237.                   </itemizedlist>
  1238.                 </sect2>
  1239.  
  1240.     </sect1>
  1241. </chapter>
  1242.